package com.job.springsea.work0707;

import java.util.Arrays;

/**
 * @author 于春海
 * @version 1.0
 * @since 2022-07-07 16:51:46
 */
public class MyHelper {
    private String name;
    private int age;
    private String major;

    public String getName() {
        return name;
    }

    public int getAge() {
        return age;
    }

    public String getMajor() {
        return major;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void setMajor(String major) {
        this.major = major;
    }

    public MyHelper() {
    }

    public void introduce(){
        System.out.println("我的名字:"+name+",我的年龄:"+age+",我的专业:"+major);
    }
    public double findMid(double[] arr ){
        Arrays.sort(arr);
        int len= arr.length;
        double mid,ave;
        if((len&2)==0){
            mid=(arr[len/2-1]+arr[len/2])/2;
        }else{
            mid=arr[len/2];
        }
        double sum=0;
        for (double v : arr) {
            sum = sum + v;
        }
        ave=sum/len;
        if(mid<ave)
        {
            return ave;
        }else{
            return mid;
        }
    }

    public static void main(String[] args) {
        MyHelper helper=new MyHelper();
        helper.setAge(20);
        helper.setName("Jack");
        helper.setMajor("计算机科学与技术");
        helper.introduce();
        double[] arr={1,2,3,4,5,6,7,8,9};
        double res=helper.findMid(arr);
        System.out.println(res);
        //double类型数据怎样打印出整数
    }


}